<?php
declare (strict_types = 1);

namespace app\command;

use app\model\order\Orders;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class SyncTask extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('syncTask')
            ->setDescription('每分钟运行一次的定时任务');
    }

    protected function execute(Input $input, Output $output)
    {
        //取消24小时不支付订单
        $order_list = Orders::where("status",0)->where("add_time","<",time()-86400)->select()->toArray();
        $orders = array_column($order_list,'id');
        Orders::whereIn('id',$orders)->update(['status'=>5,'is_del' => 1]);
        // 指令输出
        $output->writeln('app\command\synctask');
    }
}
